﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace LockTes
{
    class Program
    {
        static object lockObj = new object();
        static void Main(string[] args)
        {

            Thread th = new Thread(ThreadFun);
            th.IsBackground = true;
            th.Start();

            lock (lockObj)
            {
                Console.WriteLine("Main" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                Thread.Sleep(3000);
            }
            Thread.Sleep(3000);
        }

        static void ThreadFun() {
            lock (lockObj) {
                Console.WriteLine("ThreadFun" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                Thread.Sleep(3000);
            }
        }


    }
}
